package hpasDAO;

import hpasDataEntities.DetailedType;
import hpasDataEntities.Hardware;

import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;

public class DetailedTypeDAO
{
    private Connection conn;
    private DetailedTypeDAO detailedTypeDAO;
    /** 创建数据库访问接口 **/
    public DetailedTypeDAO()
    {
        try
        {
            connect();
        }
        catch (SQLException e)
        {
            JOptionPane.showMessageDialog(null,"数据库建立连接失败",
                    "错误",JOptionPane.ERROR_MESSAGE);
        }
        catch (ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(null,"找不到MySQL驱动程序",
                    "错误",JOptionPane.ERROR_MESSAGE);
        }
    }
    /** 创建连接 **/
    private void connect() throws SQLException, ClassNotFoundException
    {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hpas","root", "niuniu53");
    }
    /** 绑定小类别查询接口 **/
    public void setDetailedTypeDAO(DetailedTypeDAO detailedTypeDAO)
    {
        this.detailedTypeDAO = detailedTypeDAO;
    }
    /** 添加小类别 **/
    public void addDetailedType(DetailedType detailedType) throws SQLException
    {}
    /** 删除小类别 **/
    public void removeDetailedType(DetailedType detailedType) throws SQLException
    {}
    /** 查询小类别 **/
    public DetailedType getDetailedType() throws SQLException
    {
        return null;
    }
    /** 修改小类别 **/
    public void updateDetailedType(DetailedType detailedType) throws SQLException
    {}
    /** 查询小类别下所有硬件 **/
    public ArrayList<Hardware> getAllAssociatedHardwares(DetailedType detailedType) throws SQLException
    {
        return null;
    }
}
